#include "DisplayControl.h"
#include "GpioLeds.h"

static const int CONTRAST_INIT = 50;
static const int CONTRAST_MIN = 0;
static const int CONTRAST_MAX = 100;
static int contrast = CONTRAST_INIT;
static bool crossMode = true;
static OutMode disOutMode = OutMode::SUPERPOSITION;
static GpioLeds lcdShtdn("lcd_shtdn");

void InitDisplay()
{
    SetContrast(CONTRAST_INIT);
    SetCrossMode(false);
    SetOutMode(OutMode::SUPERPOSITION);
//    EnableDisplay();
}

void SetContrast(int value)
{
    if(value>CONTRAST_MAX)
    {
        contrast = CONTRAST_MAX;
    }
    else if(value<CONTRAST_MIN)
    {
        contrast = CONTRAST_MIN;
    }
    else
    {
        contrast = value;
    }
}

void IncContrast(int step)
{
//    contrast+=step;
    SetContrast(contrast+step);
}

void DecContrast(int step)
{
//    contrast-=step;
    SetContrast(contrast - step);
}

int GetContrast()
{
    return contrast;
}

void SetCrossMode(bool mode)
{
    crossMode = mode;
}

bool GetCrossMode()
{
    return crossMode;
}

void SetOutMode(OutMode mode)
{
    disOutMode = mode;
}

OutMode GetOutMode()
{
    return disOutMode;
}

void EnableDisplay()
{
    lcdShtdn.SetActive(true);
}

void DisableDisplay()
{
    lcdShtdn.SetActive(false);
}
